/**
 * 
 */
package info.niwota.profile;


import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Window;
import android.widget.ListView;

/**
 * @author qiangli
 *
 */
public class RecentListActivity extends PeerListActivity {

	private static final String TAG = "RecentListActivity";

	@Override
	protected void onPause() {
		super.onPause();
		if (Debug.DEBUG) {
			Log.d(TAG, "onPause");
		}
	}


	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_LEFT_ICON);
		setContentView(R.layout.peer_list);
	
		//
		adapter = new PeerListAdapter(this, PeerListAdapter.SORT_RECENT);
		//
		final ListView lv = getListView();
		lv.setItemsCanFocus(true);
		lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
		//
		registerForContextMenu(lv);
		
		getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
				R.drawable.icon);
	
		if (savedInstanceState != null) {
			updateUi();
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		if (Debug.DEBUG) {
			Log.d(TAG, "onResume");
		}
		
		adapter.load();
		getListView().setAdapter(adapter);
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (Debug.DEBUG) {
			Log.d(TAG, "onKeyDown " + keyCode);
		}
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
}
